var t = getApp(), a = 2 * t.globalData.statusBarHeight + 20;

Page({
    data: {
        statusBarHeight: a,
        posterShow: !1,
        navShow: !0,
        page: 1,
        plugin_name: "问卷调查"
    },
    onLoad: function(t) {
        this.getData();
    },
    goSearch: function(t) {
        wx.navigateTo({
            url: "/packageE/questionnaire/questionsSearch/questionsSearch"
        });
    },
    tapshow: function(t) {
        this.setData({
            posterShow: !0
        });
    },
    goBanner: function(t) {
        console.log(t.currentTarget.dataset.link);
        var a = t.currentTarget.dataset.link;
        try {
            wx.navigateTo({
                url: a
            });
        } catch (t) {
            console.log(t);
        }
    },
    back: function(t) {
        wx.navigateBack({
            delta: 1
        });
    },
    posterClose: function(t) {
        this.setData({
            posterShow: !1
        });
    },
    detail: function(t) {
        var a = t.currentTarget.dataset.item, e = Date.parse(new Date());
        if ("ios" == wx.getSystemInfoSync().platform && (a.start_time = a.start_time.replace(/\./g, "/"), 
        a.end_time = a.end_time.replace(/\./g, "/")), a.start_time && a.end_time) {
            if (e < Date.parse(new Date(a.start_time))) return void wx.showToast({
                title: "".concat(this.data.plugin_name, "未开始"),
                icon: "none"
            });
            if (e > Date.parse(new Date(a.end_time))) return void wx.showToast({
                title: "".concat(this.data.plugin_name, "已结束"),
                icon: "none"
            });
        }
        wx.navigateTo({
            url: "/packageE/questionnaire/questions/questions?id=" + a.id + "&tag=index"
        });
    },
    gohistory: function(t) {
        wx.navigateTo({
            url: "/packageE/questionnaire/history/history"
        });
    },
    onReady: function() {},
    onShow: function() {
        var t = getCurrentPages();
        console.log(t[t.length - 1].route);
        try {
            "packageE/questionnaire/surveyResult/surveyResult" === t[t.length - 1].route && this.setData({
                navShow: !1
            });
        } catch (t) {
            console.log(t);
        }
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.isLoading) {
            var t = this.data.page + 1;
            this.setData({
                page: t
            }), this.getMoreData();
        }
    },
    onShareAppMessage: function() {},
    getData: function() {
        var a = this, e = t.getNetAddresss("plugin.questionnaire.api.index.indexInfo");
        t._getNetWork({
            url: e,
            data: {
                index: "index",
                page: a.data.page
            },
            success: function(t) {
                var e = t.data;
                console.log(e), 1 == e.result ? (a.setData({
                    info: e.data.index,
                    list: e.data.index.list.data,
                    current_page: e.data.index.list.current_page,
                    last_page: e.data.index.list.last_page,
                    link: e.data.index.link,
                    plugin_name: e.data.plugin_name
                }), a.data.current_page >= a.data.last_page ? a.setData({
                    isLoading: !1
                }) : a.setData({
                    isLoading: !0
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this, e = t.getNetAddresss("plugin.questionnaire.api.index.indexInfo");
        t._getNetWork({
            url: e,
            data: {
                index: "index",
                page: a.data.page
            },
            success: function(t) {
                var e = t.data;
                console.log(e), 1 == e.result ? (a.setData({
                    info: e.data.index,
                    list: a.data.list.concat(e.data.index.list.data),
                    current_page: e.data.index.list.current_page,
                    last_page: e.data.index.list.last_page,
                    link: e.data.index.link
                }), a.data.current_page >= a.data.last_page ? a.setData({
                    isLoading: !1
                }) : a.setData({
                    isLoading: !0
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});